In [1]:
import tweepy
import csv
from time import sleep
import re
import random
import itertools
consumer_key = ''
consumer_secret = ''
access_token_key = ''
access_token_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token_key, access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
In [2]:
for tweet in tweepy.Cursor(api.search,q="Machine Learning").items(100):
#print tweet.id
try:
api.create_favorite(tweet.id)
sleep(10)
except Exception as e:
print "fail", str(e)
sleep(1)
In [3]:
compliments = '''You're a smart cookie.
I bet you make babies smile.
You have impeccable manners.
I like your style.
I appreciate you.
You are the most perfect you there is.
You are enough.
You're strong.
Your perspective is refreshing.
You light up the room.
You deserve a hug right now.
You should be proud of yourself.
You're more helpful than you realize.
You have a great sense of humor.
You've got all the right moves!
Is that your picture next to "charming" in the dictionary?
Your kindness is a balm to all who encounter it.
You're all that and a super-size bag of chips.
On a scale from 1 to 10, you're an 11.
You are brave.
You're even more beautiful on the inside than you are on the outside.
You have the courage of your convictions.
If cartoon bluebirds were real, a bunch of them would be sitting on your shoulders singing right now.
You are making a difference.
You're like sunshine on a rainy day.
You bring out the best in other people.
Your ability to recall random factoids at just the right time is impressive.
You're a great listener.
How is it that you always look great, even in sweatpants?
Everything would be better if more people were like you!
I bet you sweat glitter.
You were cool way before hipsters were cool.
Hanging out with you is always a blast.
You always know -- and say -- exactly what I need to hear when I need to hear it.
You may dance like no one's watching, but everyone's watching because you're an amazing dancer!
When you say, "I meant to do that," I totally believe you.
When you're not afraid to be yourself is when you're most incredible.
That thing you don't like about yourself is what makes you so interesting.
You're wonderful.
Jokes are funnier when you tell them.
You're better than a triple-scoop ice cream cone. With sprinkles.
You're one of a kind!
You're inspiring.
If you were a box of crayons, you'd be the giant name-brand one with the built-in sharpener.
You should be thanked more often. So thank you!!
Our community is better because you're in it.
Someone is getting through something hard right now because you've got their back.
You have the best ideas.
You always know how to find that silver lining.
Everyone gets knocked down sometimes, but you always get back up and keep going.
You're a candle in the darkness.
You're a great example to others.
You always know just what to say.
You're always learning new things and trying to better yourself, which is awesome.
If someone based an Internet meme on you, it would have impeccable grammar.
You could survive a Zombie apocalypse.
You're more fun than bubble wrap.
When you make a mistake, you fix it.
Who raised you? They deserve a medal for a job well done.
You're great at figuring stuff out.
Your voice is magnificent.
You're like a breath of fresh air.
Your creative potential seems limitless.
Actions speak louder than words, and yours tell an incredible story.
Somehow you make time stop and fly at the same time.
When you make up your mind about something, nothing stands in your way.
You seem to really know who you are.
Any team would be lucky to have you on it.
In high school I bet you were voted "most likely to keep being awesome."
I bet you do the crossword puzzle in ink.
You're even better than a unicorn, because you're real.
How do you keep being so funny and making everyone laugh?
You have a good head on your shoulders.
You're really something special.
'''.split('\n')
adj = '''accepting,active,admirable,
affirming,ageless,agreeable,
abundant,accomplished,accurate,adaptable,
agile,alert,ambitious,appreciative,
attentive,aware,authentic,attactive,
affectionate,amazing,awesome,amusing
beautiful,benficial,best,
better,blessed,blissful,blooming,blossoming,
bold,brilliant,brave
creative,capable,certain,
challenging,charming,clean,comfortable,
charitable,careful,cool,charitable,cheerful,
clear,committed,competent,concentration,
compassionate,confident,consistent,convincing,
courageous,courteous,cooperative,curious,
clear-headed,considerate
desirable,decent,delicate,delicious,do-er,
dynamic,daring,delightful,
dependable,desirable,devoted,determined,
diligent,disciplined,diverse,drive,dazzling,
divine
excellent,educated,efficient,empathetic,easy,
enabling,energetic,engaging,enjoyable,eager,
effective,elated,elegant,encouraging,
enthusiastic,exciting,experienced,expert,
explorer,expressive,enlightened,exalted,
empowered,exhilirating,engrossing,ecstatic,
entrancing,enlivened
fantastic,fabulous,fair,faithful,famous,
favorite,flexible,family-oriented,focused,
flourishing,forgiving,free,fun,frugal,friendly,
fascinating,fulfilled,foody,feisty,festive
good,glowing,generous,genius,genuine,giving,
goingtheextramile,grace,gratitude,growing,
grounded,glorious,groovy,giddy,glad
hopeful,hot,happy,harmonious,healthy,heartwarming,helpful,honest,humorous,human,
hero,holy,honesty,honorable,hospitable,
humble,halo
imaginative,inspiring,ideal,incredible,
interesting,innovative,improving,imaginative,
independent,ingenius,insightful,inspiring,
integrity,intelligent,involved,inclusive,
intriguing,intuitive
joyful,jokey,jolly,jovial,just,jazzy,
jaunty,jubilant,junior,jumpy,juvenile
kind,killer,keen,knowledgable,
kool
learner,leader,logical,lucky,
magnificent,meaningful,majestic,
marvelous,motivating,miraculous,magic,
makingadifference,masterful,mindful,modest,
merciful,mellow,moving
nice,noble,neat,new,nurturing,noisy,normal,
noteworthy,novel,nutty,
outstanding,optimistic,open-hearted,original,
open-minded,obedient,organized,overthetop,
outofthisworld
perfect,positive,peaceful,paradisiacal,
passionate,powerful,prepared,perceptive,
persistent,pleasing,prosperous,playful,
purposedriven,present
quality,quiet,quaint,qualified,quick,quirky
quotable
respectful,radiant,ready,rockin’,relaxing,
remarkable,rational,respectful,responsible,
resourceful,risktaker,romantic,righteous,
resilient,rad
super,smiley,soulmate,special,
selfless,secure,safe,sincere,stylish,sympathetic,
strong,sparkly,sunshiney,spontaneous,sweet,
supportive
true,teachable,trusting,teamplayer,thankful,
timely,tranquil,tender,thrilling,ticklish
unique,uplifting,ultimate,unconditional,
upgrade,useful,unifying,understanding
valuable,valid,viable,
vibrant
worthy,wild,wacky,wonderful
'''
adj = '''awesome, great, perfect, amazing, wonderful, eye-opening, unique, wild, rad, special, outofthisworld, original, inspiring,
logical, magnificent, marvelous, magical, cool, nuts, humbling, great, kool, clear, futuristic, brilliant, fantastic,
Brilliant
exalting ennobling
impressive
important-looking expansive formidable mind-boggling grand spectacular
splendid
sensational awe-inspiring brilliant fulgurous astonishing stunning
Compelling
Enriching
Epic
Flawless
Groundbreaking
Gut-wrenching
Headline-worthy
Impeccable
Insightful
Kick-Ass
Legendary
Luminous
Masterful
Notable
Pioneering
Pitch-Perfect
Pivotal
Provocative
Rich
Riveting
Sensational
Stellar
Thought-Provoking
Unforgettable
Vibrant
'''
adj = set(re.findall(r"[\w'-]+", adj))
In [4]:
compliments += compliments #oversample the less obvious ones
compliments += compliments
compliments += [w.title() + '!' for w in adj]
compliments += ['In one word: ' + w + '.' for w in adj]
compliments += ['That was ... ' + w + '?' for w in adj]
In [5]:
liked_text = []
for tweet in itertools.chain(tweepy.Cursor(api.search,q="Artificial Intelligence").items(100),
tweepy.Cursor(api.search,q="Machine Learning").items(100),
tweepy.Cursor(api.search,q="#AI").items(100),
tweepy.Cursor(api.search,q="DataScience").items(100)):
try:
if tweet.text[0:2] == 'RT': continue
if ' RT ' in tweet.text: continue
if 'IBM' in tweet.text: continue
if tweet.in_reply_to_status_id != None: continue
if tweet.lang != "en": continue
if tweet.text in liked_text: continue
liked_text += [tweet.text]
reply = random.choice(compliments)
screenName = tweet.user.screen_name
replyText = '@' + screenName + ' ' + reply
print '** Original -', tweet.text
print '** Reply ({}) -'.format(len(liked_text)), replyText
api.update_status(replyText, in_reply_to_status_id=tweet.id_str )
sleep(10)
except:
print "fail"
sleep(1)